package com.foo.designpattern.strategy;

/**
 * com.foo.designpattern.strategy
 * Created with IntelliJ IDEA.
 * Created by jiang on 2016-05-17 14:32.
 *
 * @Description 环境角色(Context)
 * 本类持有一个Strategy的引用。
 */

public class Price {
    // 持有一个具体的策略对象
    private MemberStrategy memberStrategy;

    /**
     * 构造函数，传入一个具体的策略对象
     *
     * @param memberStrategy 具体的策略对象
     */
    public Price(MemberStrategy memberStrategy) {
        this.memberStrategy = memberStrategy;
    }

    /**
     * 计算图书的价格
     *
     * @param bookPrice 图书的原价
     * @return 计算出的打折后的价格
     */
    public double quote(double bookPrice) {
        return this.memberStrategy.calcPrice(bookPrice);
    }
}
